package org.springblade.modules.repair.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springblade.modules.repair.vo.MsgTypeVO;

import java.util.ArrayList;
import java.util.List;

/**
 * @Date 9:00 2022/3/11
 * @Description {
 *   关联模板周期类型
 * }
 * @Author lsay
 **/
@Getter
@AllArgsConstructor
public enum MsgTypeEnum {

	ELEVATOR_RELEVANCE(1,"项目申请关联"),
	ELEVATOR_PARTS_OFFER(2,"配件报价审批"),
	ELEVATOR_PARTS_SHIPMENTS(3,"配件发货审批"),
	ELEVATOR_PARTS_DISPATCHERS(4, "配件任务调度"),
	ELEVATOR_CHECK_DISPATCHERS(6, "质检问题处理"),
	ELEVATOR_SCORE(7, "待评分工单提醒"),
	ELEVATOR_RESCUE_ARRIVE(8, "救援到达风险提醒"),
	CERT_EXPIRED(9, "证件到期提醒"),
	PLAN_NO(10, "合同期内无剩余排期"),
	PLAN_NEXT(11, "下次保养计划存在逾期风险"),
	PLAN_HISTORY_IMAGE(12, "AI结果人工审核提醒"),
	PARTS_MSG_APPROVE(13, "信息审核"),
	BY_MSG(14, "保养工单提醒"),
	HAS_CONTRACT_NO_PLAN_YES(15, "昨日已续保但未排期项目"),
	HAS_CONTRACT_NO_PLAN(16, "累计已续保但未排期项目"),
	ABARBEITUNG(17, "整改工单提醒"),
	BY_SCH_COM_RISKS(18, "保养排期人数合规风险"),
	BY_SCORE_NO_PASS(19, "保养评分不合规"),
	ZG_TIME_OUT(20, "整改工单逾期未完成"),
	JY_TASK_WARNING(21, "救援任务跟踪预警"),
	;

	final int id;

	final String name;

	/**
	 * 根据id获取枚举name值
	 * @param id 枚举id
	 * @return name值
	 */
	public static String getName(Integer id){
		if (id == null) {
			return null;
		}
		MsgTypeEnum[] values = MsgTypeEnum.values();
		for(MsgTypeEnum msgTypeEnum :values){
			Integer enumId = msgTypeEnum.getId();
			if(id.equals(enumId)){
				return msgTypeEnum.getName();
			}
		}
		return null;
	}

	/**
	 * 返回类型集合
	 * @return
	 */
	public static List<MsgTypeVO> getMsgType() {
		List<MsgTypeVO> list = new ArrayList<>();
		MsgTypeEnum[] msgTypeEnums = MsgTypeEnum.values();
		for (MsgTypeEnum msgTypeEnum : msgTypeEnums) {
			MsgTypeVO msgTypeVO = new MsgTypeVO();
			msgTypeVO.setTypeId(msgTypeEnum.getId());
			msgTypeVO.setTypeName(msgTypeEnum.getName());
			list.add(msgTypeVO);
		}
		return list;
	}

}
